package DynamicProgramming;

import java.util.Arrays;

public class _518_CoinChange2 {
    public int change(int amount, int[] coins) {
        Arrays.sort(coins);
        int[] res = new int[amount + 1];
        res[0] = 1;
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                res[i] += res[i - coin];
            }
        }
        return res[amount];
    }
}
